package com.matt.components.intercepter;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * *******************************
 * Created by Ron.
 * form com.matt
 * on 2017/5/18
 * *******************************
 */
@Configuration
public class WebInterceptorConfiguration extends WebMvcConfigurerAdapter{

    @Bean
    ActionLogInterceptor actionLogInterceptor() {
        return new ActionLogInterceptor();
    }

    @Bean
    AuthInterceptor authInterceptor(){
        return new AuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(actionLogInterceptor())
                .addPathPatterns("/pad/**")
                .addPathPatterns("/web/**")
                .addPathPatterns("/api/**")
                .addPathPatterns("/eapi/**")
                .addPathPatterns("/capi/**")
                .excludePathPatterns("/web/group/static_photo_album/download")
                .excludePathPatterns("/scheduler/**", "/other_system/**")
                .excludePathPatterns("/phone/**");

        registry.addInterceptor(authInterceptor())
                .addPathPatterns("/api/WebServices/**")
                .addPathPatterns("/scheduler/**", "/other_system/**", "/data_transfer/**")
                .excludePathPatterns("/api/iot/tianbo/**")
        ;
    }
}
